
import axios from "axios";
const request = axios.create({
  baseURL: "https://pre-mbuddy.sdbattery.com/",
  timeout: 5000
});

request.interceptors.request.use(
  config => {
    return config;
  },
  error => {
    console.log(error);
    return Promise.reject(error);
  }
);

request.interceptors.response.use(
  response => {
    if (response && response.status === 200) {
      return response.data;
    } else {
      return Promise.reject("服务器异常");
    }
  },
  error => {
    return Promise.reject(error);
  }
);

export default request;
